<template>
  <section class="checkarea">
    <input type="checkbox" :id="title" v-model="myval" @click="changeval" />
    <label :for="title" class="checklabel">
      <span> √ </span>
      <span><slot></slot></span>
    </label>
  </section>
</template>
<script>
export default {
  // props:['val','title'],
  props: {
    val: {
      type: Boolean,
    },
    title: {
      type: String/Number,
    },
    myval: {
      type: Boolean,
    },
    keys: {
      type: Number,
    },
  },
  data() {
    return {
      // myval:true
    };
  },
  methods: {
    changeval() {
      if (typeof(this.title)===typeof(1)) {
        this.$store.commit("cart/fan", this.title); 
        return false;
      }
      // console.log( typeof(this.title)===typeof(1));
      this.myval = !this.myval;
      if (this.title == "quan") {
        this.$store.commit("cart/quan", this.myval);
        return false;
      }
      this.$emit("update:val", this.myval);
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/assets/css/color.scss";
.checklabel {
  span:nth-child(1) {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 1px solid #ccc;
    text-align: center;
    line-height: 18px;
    color: #fff;
  }
}
.checkarea > input:checked + label {
  span {
    color: $xtxColor;
  }
  span:nth-child(1) {
    border: 1px solid $xtxColor;
  }
}
</style>
